﻿﻿<template>
    <el-card class="form-container">
        <el-form :model="dataForm" ref="dataForm" :rules="dataRule"  @keyup.enter.native="dataFormSubmitHandle()" label-width="90px">
                                                                            <el-form-item label="订单编号" prop="orderCode">
                        <el-input v-model="dataForm.orderCode" placeholder="请输入订单编号"></el-input>
                    </el-form-item>
                                                                <el-form-item label="操作人编号" prop="operationCode">
                        <el-input v-model="dataForm.operationCode" placeholder="请输入操作人编号"></el-input>
                    </el-form-item>
                                                                <el-form-item label="操作人名称" prop="operationName">
                        <el-input v-model="dataForm.operationName" placeholder="请输入操作人名称"></el-input>
                    </el-form-item>
                                                                <el-form-item label="操作内容" prop="operationContent">
                        <el-input v-model="dataForm.operationContent" placeholder="请输入操作内容"></el-input>
                    </el-form-item>
                                                                <el-form-item label="订单状态" prop="orderStatus">
                        <el-input v-model="dataForm.orderStatus" placeholder="请输入订单状态"></el-input>
                    </el-form-item>
                                                                <el-form-item label="操作时间" prop="operationTime">
                        <el-input v-model="dataForm.operationTime" placeholder="请输入操作时间"></el-input>
                    </el-form-item>
                                        <el-form-item>
                <el-button @click="cancel">取消</el-button>
                <el-button type="primary"  @click="submit('dataForm')">确定</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</template>

<script>
    import {createOrderOperationRecord} from '@/api/admin/orderOperationRecord'
    export default{
        name: 'add-orderOperationRecord',
        data(){
            return {
                dataForm: {
                                                                                                                    orderCode : ''
                                                                                                operationCode : ''
                                                                                                operationName : ''
                                                                                                operationContent : ''
                                                                                                orderStatus : ''
                                                                                                operationTime : ''
                                                            },
                dataRule: {
                                                                                                                    orderCode: [
                            {
                                required: true,
                                message: '请输入订单编号',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                operationCode: [
                            {
                                required: true,
                                message: '请输入操作人编号',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                operationName: [
                            {
                                required: true,
                                message: '请输入操作人名称',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                operationContent: [
                            {
                                required: true,
                                message: '请输入操作内容',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                orderStatus: [
                            {
                                required: true,
                                message: '请输入订单状态',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                operationTime: [
                            {
                                required: true,
                                message: '请输入操作时间',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                            }
            }
        },
        methods:{
            cancel(){
                this.$router.go(-1)
            },
            submit(){
                const set = this.$refs;
                set['dataForm'].validate((valid) => {
                    if (!valid) {
                        return false
                    }
                    createOrderOperationRecord(this.dataForm).then(() => {
                        this.$notify({
                            title: '添加成功',
                            message: '添加成功',
                            type: 'success',
                            duration: 2000,
                            onClose: this.$router.go(-1)
                        })
                    })
                })
            }
        }
    }
</script>

<style>
</style>
